﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using GalaSoft.MvvmLight.Command;
using GalaSoft.MvvmLight;
using System.Windows.Input;
using System.Windows;

namespace TriviaViewModel
{
    public class WizardViewBase:GalaSoft.MvvmLight.ViewModelBase
    {

        int numberOfShowAboutClicks = 0;

        /// <summary>
        /// binded to the content control in the main window
        /// </summary>
        private ViewModelBase _currentViewModel;
        public ViewModelBase CurrentViewModel
        {
            get { return _currentViewModel; }
            set
            {
                if (_currentViewModel != value)
                {
                    _currentViewModel = value;
                    RaisePropertyChanged("CurrentViewModel");
                }
            }
        }
        private AddQuestionViewModel _addQuestionVModel;

        public AddQuestionViewModel AddQuestionVModel
        {
            get { return _addQuestionVModel; }
            set {
                if (_addQuestionVModel != value)
                {
                    _addQuestionVModel = value;
                    RaisePropertyChanged("AddQuestionVModel");
                }
            }
        }

        private EntryViewModelWizard _entranceViewModel;
        public EntryViewModelWizard EntranceViewModel
        {
            get { return _entranceViewModel; }
            set
            {
                if (_entranceViewModel != value)
                {
                    _entranceViewModel = value;
                    RaisePropertyChanged("EntranceViewModel");
                }
            }
        }
        
        

        private DifficultyAndTopicViewModel _difficultyTopicViewModel;
        public DifficultyAndTopicViewModel DifficultyTopicViewModel
        {
            get { return _difficultyTopicViewModel; }
            set
            {
                if (_difficultyTopicViewModel != value)
                {
                    _difficultyTopicViewModel = value;
                    RaisePropertyChanged("DifficultyTopicViewModel");
                }
            }
        }

        private ScoreBoardViewModelWizard _scoreBoardViewModel;
        public ScoreBoardViewModelWizard ScoreBoardViewModel
        {
            get { return _scoreBoardViewModel; }
            set
            {
                if (_scoreBoardViewModel != value)
                {
                    _scoreBoardViewModel = value;
                    RaisePropertyChanged("ScoreBoardViewModel");
                }
            }
        }
    

     

        private Visibility _isButtonsVisible;
        public Visibility IsButtonsVisible
        {
            get { return _isButtonsVisible; }
            set
            {
                if (_isButtonsVisible != value)
                {
                    _isButtonsVisible = value;
                    RaisePropertyChanged("IsButtonsVisible");
                }
            }
        }

        private Visibility _isTabControlVisible;
        public Visibility IsTabControlVisible
        {
            get { return _isTabControlVisible; }
            set
            {
                if (_isTabControlVisible != value)
                {
                    _isTabControlVisible = value;
                    RaisePropertyChanged("IsTabControlVisible");
                }
            }
        }

        private Visibility _isGameVisible;
        public Visibility IsGameVisible
        {
            get { return _isGameVisible; }
            set
            {
                if (_isGameVisible != value)
                {
                    _isGameVisible = value;
                    RaisePropertyChanged("IsGameVisible");
                }
            }
        }

     

        //public ICommand GoToScoreBoardCommand { get; set; }
        //public ICommand GoToMainWindowCommand { get; set; }
        //public ICommand GoToGameCommand { get; set; }
        //public ICommand GoToQestionWizardCommand { get; set; }
        //public ICommand EndGameCommand { get; set; }


        public WizardViewBase()
        {

            IsGameVisible = Visibility.Collapsed;
            IsTabControlVisible = Visibility.Visible;
            if (ViewModelBase.IsInDesignModeStatic) return;
            AddQuestionVModel = new AddQuestionViewModel();
            EntranceViewModel = new EntryViewModelWizard();
            ScoreBoardViewModel = new ScoreBoardViewModelWizard();
            DifficultyTopicViewModel = new DifficultyAndTopicViewModel();
           
      
            //WizardViewBase._entranceViewModel = new EntryViewModelWizard();
            //WizardViewBase._questionViewModel = new QuestionWizardViewModel();
            //IsButtonsVisible = Visibility.Visible;
           
            //CurrentViewModel = WizardViewBase._entranceViewModel;


            //_gameViewModel.GoToGameCommand = new RelayCommand(() => ExecuteGoToGameCommand());
            //GoToGameCommand = new RelayCommand(() => ExecuteGoToGameCommand());
            //EndGameCommand = new RelayCommand(() => EndGameCommandExecute());
            //GoToScoreBoardCommand = new RelayCommand(() => ExecuteGoToScoreBoardCommand());
            //GoToMainWindowCommand = new RelayCommand(() => ExecuteGoToStartPageCommand());
            //GoToQestionWizardCommand = new RelayCommand(() => ExecuteGoToQestionWizardCommand());
       

        }
      
        /// <summary>
        /// method of the command that switches current view model to score board view model
        /// </summary>
        //private void ExecuteGoToScoreBoardCommand()
        //{
        //    WizardViewBase._scoreBoardViewModel = new ScoreBoardViewModelWizard();
        //    CurrentViewModel = WizardViewBase._scoreBoardViewModel;

        //    IsButtonsVisible = Visibility.Collapsed;
        //}
        /// <summary>
        /// method of the command that switches current view model to start page view model
        /// </summary>
        //private void ExecuteGoToStartPageCommand()
        //{
        //    WizardViewBase._entranceViewModel = new EntryViewModelWizard();
        //    CurrentViewModel = _entranceViewModel;
           
        //    IsButtonsVisible = Visibility.Visible;
        //}


        /// <summary>
        /// the action that changed the current view model to game view model and sets the game view model properties
        /// </summary>
        private void ExecuteGoToGameCommand()
        {
            //GameViewModel = new GameViewModelWizard();
            //IsGameVisible = Visibility.Visible;
            //IsTabControlVisible = Visibility.Collapsed;
            //if (EntranceViewModel.SelectedDifficulty != null && EntranceViewModel.SelectedTopic != null)
            //{
            //    IsButtonsVisible = Visibility.Collapsed;

            //    if (EntranceViewModel.UserName != null && EntranceViewModel.Password != null)
            //       GameViewModel.SetUser(EntranceViewModel.UserName, EntranceViewModel.Password);
            //    GameViewModel.SetQuestionsAndAnswers(EntranceViewModel.SelectedDifficulty, EntranceViewModel.SelectedTopic);
              
            //}
            //else
            //    System.Windows.Forms.MessageBox.Show("Choose difficulty and topic");

        }

        private void EndGameCommandExecute()
        {
        //    IsGameVisible = Visibility.Collapsed;
        //    IsTabControlVisible = Visibility.Visible;
        //    EntranceViewModel = new EntryViewModelWizard();
        //    GameViewModel = null;
        }
        //private void ExecuteGoToQestionWizardCommand()
        //{
        //    CurrentViewModel = WizardViewBase._questionViewModel;
        //    IsButtonsVisible = Visibility.Collapsed;
        //}

       
       
    }
    

      



    
}
